package main

import (
	"fmt"
	"os"
	"strings"
	"testing"
	"time"
)

func Test1() { // 低速拼接测试
	start := time.Now()
	s, sep := "", ""
	for _, arg := range os.Args[1:] {
		s += sep + arg
		sep = " "
	}
	fmt.Println(s)
	fmt.Println(time.Since(start))
}

func Test2() { // 高速拼接测试
	start := time.Now()
	fmt.Println(strings.Join(os.Args[1:], " "))
	fmt.Println(time.Since(start))
}

func BenchmarkTest1(b *testing.B) { // 基准测试
	for i := 0; i < b.N; i++ {
		Test1()
	}
}

func BenchmarkTest2(b *testing.B) {
	for i := 0; i < b.N; i++ {
		Test2()
	}
}

func main() {
	Test1()
	Test2()
}
